﻿#region Copyrigth and License
/*==============================================================================
 *  Copyright (c) cndotnet.org Corporation.  All rights reserved.
 * ===============================================================================
 * This code and information is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the implied warranties
 * of merchantability and fitness for a particular purpose.
 * ===============================================================================
 * Licensed under the GNU General Public License (GPL) v2
 * http://www.cndotnet.org/ucenter
 * ==============================================================================*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UCenter.ContactService.Email {
    public class EmailServiceManager {
        #region Fields

        #endregion

        #region Constructors

        #endregion

        #region Properties

        #endregion

        #region Events

        #endregion

        #region Methods
        public static MailContractCollection GetContracts(string accountID, string pwd) {
            int index = accountID.IndexOf("@");
            if (index == -1) {
                throw new ArgumentException("accountID must be an email!");
            }
            MailContractCollection mc = new MailContractCollection();
            string emailSystem = accountID.Substring(index + 1).ToLower();
            IEmailService intanceService = null;
            if (emailSystem == "126.com") {
                intanceService = new Email126Service();
            }
            else if (emailSystem == "163.com") {
                intanceService = new Email163Service();
            }
            else if (emailSystem == "vip.163.com") {
                intanceService = new Email163VipService();
            }
            else if (emailSystem == "sohu.com") {
                intanceService = new EmailSohuService();
            }
            else if (emailSystem == "vip.sohu.com") {
                intanceService = new EmailSohuVipService();
            }
            else if (emailSystem == "sina.com.cn") {
                intanceService = new EmailSinaService();
            }
            else if (emailSystem == "vip.sina.com") {
                intanceService = new EmailSinaVipService();
            }
            else if (emailSystem == "yahoo.com") {
                intanceService = new EmailYahooService();
            }
            else if (emailSystem == "ymail.com") {
                intanceService = new EmailYmailService();
            }
            else if (emailSystem == "rocketmail.com") {
                intanceService = new EmailRocketmailService();
            }
            else if (emailSystem == "yahoo.cn") {
                intanceService = new EmailCnYahooService();
            }
            else if (emailSystem == "yahoo.com.cn") {
                intanceService = new EmailYahooComCnService();
            }
            else if (emailSystem == "tom.com") {
                intanceService = new EmailTomService();
            }
            else if (emailSystem == "21cn.com") {
                intanceService = new Email21CnService();
            }
            else if (emailSystem == "hotmail.com") {
                intanceService = new EmailHotmailService();
            }
            else if (emailSystem == "live.cn") {
                intanceService = new EmailLiveService();
            }
            else if (emailSystem == "live.com") {
                intanceService = new EmailLiveComService();
            }
            else if (emailSystem == "msn.com") {
                intanceService = new EmailMsnService();
            }
            else if (emailSystem == "gmail.com") {
                intanceService = new EmailGmailService();
            }
            if (intanceService == null) {
                throw new ArgumentException("sorry,we have not implemented getting contract list of this email!");
            }
            string uid = accountID.Substring(0,index);
            return intanceService.GetContracts(uid, pwd);
        }
        #endregion       
    }
}
